package gwtappcontainer.client;

import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.user.client.ui.HasHTML;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.HasWidgets;


public class ContainerPresenter {
	public interface IView {
		HasText getTitleLabel();		
		HasHTML getSignInLink();
		SpanElement getUserIdSpanElement();
		HasWidgets getAppArea();
	}
	
	private IView containerView;	
	
	public ContainerPresenter(IView v) {
		containerView = v;				
	}
		
	public void setTitle(String title) {
		containerView.getTitleLabel().setText(title);		
	}
	
	public void setUser(String email) {
		containerView.getUserIdSpanElement().setInnerText(email);
	}
	
	public void setSignoutLink(String url) {
		containerView.getSignInLink().setHTML("<a href=\"" + url + "\"" + ">sign out</a>");		
	}
	
	public void setSigninLink(String url) {
		containerView.getSignInLink().setHTML("<a href=\"" + url + "\"" + ">sign in with google</a>");		
	}	
	
	void renderApp(IPresenter presenter) {
		setTitle(Constants.containerTitle + " - " + presenter.getAppName());
		presenter.render(containerView.getAppArea());
	}			
}
